import React, { useState } from 'react'

export default function App() {
  const [count, setCount] = useState(0)
  return (
    <div>
      <h2>{count}</h2>
      <button
        onClick={() => {
          setCount(count + 1)
          // 后面覆盖了前面的
          setCount(count + 2)
        }}
      >
        +1
      </button>
      <button
        onClick={() => {
          // 累计
          setCount((count) => count + 1)
          setCount((count) => count + 2)
        }}
      >
        +1
      </button>
    </div>
  )
}